home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Resource for Source: C/C++
/
Resource for Source - C-C++.iso
/
codelib9
/
v_11_02
/
1102056a
< prev
next >
Wrap
Text File
|
1995-11-01
|
2KB
|
73 lines
/*****************************************************
File Name: FINANCES.H
Description: Include file for FINANCES.C
Portability: Standard C
******************************************************/
#if !defined ( FINANCES_DEFINED )
/* Prototypes for function in FINANCES.C */
double a_to_f( double i, int n );
double a_to_f_c( double r, int n );
double a_to_p( double i, int n );
double a_to_p_c( double r, int n );
double f_to_a( double i, int n );
double f_to_a_c( double r, int n );
double f_to_p( double i, int n );
double f_to_p_c( double r, int n );
double p_to_a( double i, int n );
double p_to_a_c( double r, int n );
double p_to_f( double i, int n );
double p_to_f_c( double r, int n );
/* Natural log base */
#define LN_BASE 2.718281828459
/* Macro versions of functions in FINANCES.C */
#define A_TO_F( i, n ) \
( ( pow( 1.0 + i, n ) - 1.0 ) / i )
#define A_TO_F_C( r, n ) \
( ( pow( LN_BASE, r * n ) - 1.0 ) / \
( pow( LN_BASE, r ) - 1.0 ) )
#define A_TO_P( i, n ) \
( ( pow( 1.0 + i, n ) - 1.0 ) / \
( i * pow( 1.0 + i, n ) ) )
#define A_TO_P_C( r, n ) \
( ( 1.0 - pow( LN_BASE, -( r * n ) ) ) / \
( pow( LN_BASE, r ) - 1.0 ) )
#define F_TO_A( i, n ) \
( i / ( pow( 1.0 + i, n ) - 1.0 ) )
#define F_TO_A_C( r, n ) \
( ( pow( LN_BASE, r ) - 1.0 ) / \
( pow( LN_BASE, r * n ) - 1.0 ) )
#define F_TO_P( i, n ) \
( 1.0 / pow( 1.0 + i, n ) )
#define F_TO_P_C( r, n ) \
( 1.0 / pow( LN_BASE, r * n ) )
#define P_TO_A( i, n ) \
( i * pow( 1.0 + i, n ) / \
( pow( 1.0 + i, n ) - 1.0 ) )
#define P_TO_A_C( r, n ) \
( ( pow( LN_BASE, r ) - 1.0 ) / \
( 1.0 - pow( LN_BASE, -( r * n ) ) ) )
#define P_TO_F( i, n ) \
( pow( 1.0 + i, n ) )
#define P_TO_F_C( r, n ) \
( pow( LN_BASE, r * n ) )
#endif